#include <iostream>
#include <stack>
#include <vector>

using namespace std;

bool validateStackSequences(vector<int>& pushed, vector<int>& popped) {
    stack<int> st;
    int i = 0, j = 0;
    while (i < pushed.size())
    {
        if (pushed[i] != popped[j])
        {
            st.push(pushed[i]);
            ++i;
        }
        else
        {
            i++;
            j++;
            while (!st.empty() && st.top() == popped[j])
            {
                st.pop();
                ++j;
            }
        }
    }

    while (j < popped.size() && st.top() == popped[j])
    {
        ++j;
    }

    if (!st.empty())
        return false;
    return true;
}

int main()
{
	
	return 0;
}